
import TableList from "@components/templates/customtablelist";
import { HttpBaseSettingList } from '@/service/api/views'
import { mapState,mapGetters } from "vuex";
import compUpdate from './update';
export default {
    mixins: [TableList],
    components: {
        compUpdate,
    },
    data() {
        return {
            // totals: 0,
            isMixin: true,
            Tools: {show: true},
            Tabs: {show: true},
            formData:{
                search:{
                }
            },
            Searchs: {
                show: true,
                labelWidth: 120,
            },
            Plugins: {show: true},
        }
    },
    methods: {
        ajaxRequest: HttpBaseSettingList,
        interceptRequest(params){
            if(params.search.EQ_orgId){
                params.orgId = params.search.EQ_orgId
            }
            if(params.search.EQ_consumeType){
                params.consumeType = params.search.EQ_consumeType
            }
            if(params.search.EQ_billType){
                params.billType = params.search.EQ_billType
            }
            delete params.search.EQ_orgId;
            delete params.search.EQ_consumeType;
            delete params.search.EQ_billType;
            
            return params
        },
        handleOperates(params="", type,batch) {
            if(batch===true){
                params=(params||this.checkedData.join(','))+'';
                if(!params.length) return this.$Message.warning('请选择至少一条数据');
            }
            switch (type) {
                case 'add':
                    this.$router.push({
                        name: 'settingOrgsetUpdate',
                        params: { type: "add" },
                    });
                    break;
                case 'query':
                    this.operate = {
                        title: '查看',
                        show: true,
                        width: 1200,
                        component: "compUpdate",
                        activeid: params,
                        querytype: 'query',
                        showFooter: false,
                    }
                    break;
                case 'edit':
                    var url = this.$router.resolve({
                        name: "settingOrgsetUpdate",
                        params: { type: "edit" },
                        query: { id: params },
                    });
                    window.open(url.href, '_blank');
                    break;
                case 'download':
                    this.handleWebfs(
                        process.env.VUE_APP_APIURL_SHIP + "/api/jwt/spl/freeze/exportFreezeManage",{},
                        "download"
                    );
                    break;
                
            }
        },
        getOperateNodeMap (row) {
            const { orgId } = row
            return [{
                label: this.$ct('global.common.query', { defaultValue: '查看' }),
                show: true,
                params: orgId,
                operate: 'query'
            }, {
                label: this.$ct('global.common.operation_edit', { defaultValue: '编辑' }),
                show: true,
                params: orgId,
                operate: 'edit'
            }]
        },
    },
    computed: {
        ...mapGetters('dictionary',['getSysAllList']),
        // 搜索下拉框展示内容
        SearchsData() {
            return  [
                {
                    label: '客户组织',
                    tag: 'Select',
                    options:this.getSysAllList,
                    key: 'EQ_orgId',
                    show:true,
                    props:{
                        filterable:true
                    }
                },
                {
                    label: '消费模式',
                    tag: 'Select',
                    key: 'EQ_consumeType',
                    options:[
                        {value:1,label:'后付费'},
                        {value:2,label:'预充值'},
                    ],
                    show:true,
                },
                {
                    label: '出账类型',
                    tag: 'Select',
                    key: 'EQ_billType',
                    options:[
                        {value:1,label:'实际账单'},
                        {value:2,label:'系统报价'},
                    ],
                    show:true,
                },
                
            ]
        },
        ToolsData () {
            return [
                {
                    name: "添加",
                    theme: 'primary',
                    operate: 'add',
                },
            ]
        },
        // table的展示数据
        columns() {
            return [{
                title: "操作",
                width: 90,
                render: this.getOperateNodes,
            }, {
                title: "客户组织",
                key: "orgId",
                render:(h,{row})=> {
                    return <div>
                        <a onClick={this.handleOperates.bind(this, row.orgId, 'query')}>{this.findRenderLabel(this.getSysAllList, row.orgId)}</a>
                    </div>
                },
            },{
                title: "消费模式",
                key: "consumeType",
                render:(h,{row})=> {
                    return <div>
                        {row.consumeType == 1 ? '后付费':row.consumeType == 2 ?'预充值':'--'}
                    </div>
                },
                
            },{
                title: "出账类型",
                key: "billType",
                render:(h,{row})=> {
                    return <div>
                        {row.billType == 1 ? '实际账单':row.billType == 2 ?'系统报价':'--'}
                    </div>
                },
            },
        ];
        },
        
    },

};
